package com.example.travel.Service;

import com.example.travel.domain.Messages;
import com.example.travel.mapper.MessagesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 功能：
 * 作者：lln
 * 日期：2025/3/17 12:54
 */
@Service
public class MessageServer {
    @Autowired
    private MessagesMapper messagesMapper;

    public void saveMessage(String fromUser, String toUser, String messageContent) {
        messagesMapper.saveMessage(fromUser, toUser, messageContent);
    }

    public List<Messages> getOfflineMessages(String toUser) {
        //打印
        System.out.println(messagesMapper.getOfflineMessages(toUser));
        return messagesMapper.getOfflineMessages(toUser);
    }

    public void markMessageAsRead(int messageId) {
        messagesMapper.markMessageAsRead(messageId);
    }

}
